<template>
  <div>
    <my-message v-show="isshow" :arr="arr" @close="close"></my-message>
    <my-table
      :list="showList"
      @lookMessage="lookMessage"
      @lookMan="lookMan"
    ></my-table>
  </div>
</template>

<script>
import MyTable from "./components/my-table.vue"
import MyMessage from "./components/my-message.vue"
export default {
  methods: {
    lookMessage(name) {
      this.name = name
    },
    lookMan(item) {
      this.arr.push(item)
      this.isshow = true
    },
    close() {
      this.isshow = false
      this.arr = []
    },
  },
  computed: {
    showList() {
      if (this.name === "") {
        return this.list
      } else {
        return this.list.filter((item) => item.doctor === this.name)
      }
    },
  },
  components: { MyTable, MyMessage },
  data() {
    return {
      arr: [],
      name: "",
      isshow: false,
      list: [
        {
          date: "2022-01-01",
          doctor: "张三",
          diagnosis: "感冒",
          prescription: "感冒药",
        },
        {
          date: "2022-02-01",
          doctor: "李四",
          diagnosis: "头疼",
          prescription: "止疼药",
        },
        {
          date: "2022-03-01",
          doctor: "王五",
          diagnosis: "腰痛",
          prescription: "止痛贴",
        },
      ],
    }
  },
}
</script>

<style></style>
